<template>
  <div>
    <Dog2
      v-for="(item, index) in arr"
      :key="index"
      :imgurl="item.dogImgUrl"
      :dogname="item.dogName"
      @love="fn"
    />
    <p>喜欢的狗:</p>
    <ul>
      <li v-for="(item, index) in loveStr" :key="index">{{ item }}</li>
    </ul>
  </div>
</template>

<script>
import Dog2 from "./components/Dog2.vue";
export default {
  components: { Dog2 },
  data() {
    return {
      arr: [
        {
          dogImgUrl:
            "https://scpic.chinaz.net/files/pic/pic9/202003/zzpic23514.jpg",
          dogName: "博美",
        },
        {
          dogImgUrl:
            "https://scpic.chinaz.net/files/pic/pic9/202003/zzpic23514.jpg",
          dogName: "泰迪",
        },
        {
          dogImgUrl:
            "https://scpic.chinaz.net/files/pic/pic9/202003/zzpic23514.jpg",
          dogName: "金毛",
        },
        {
          dogImgUrl:
            "https://scpic.chinaz.net/files/pic/pic9/202003/zzpic23514.jpg",
          dogName: "哈士奇",
        },
        {
          dogImgUrl:
            "https://scpic.chinaz.net/files/pic/pic9/202003/zzpic23514.jpg",
          dogName: "阿拉斯加",
        },
        {
          dogImgUrl:
            "https://scpic.chinaz.net/files/pic/pic9/202003/zzpic23514.jpg",
          dogName: "萨摩耶",
        },
      ],
      loveStr: [],
    };
  },
  methods: {
    fn(dogName) {
      this.loveStr.push(dogName);
    },
  },
};
</script>

<style>
</style>